import { Alova } from '@/utils/http/alova/index';


export interface Algorithm {
  id: number
  code: number;
  englishName: string;
  chineseName: string;
  version: string;
  level: string;
  is_used: boolean;
  is_installed: boolean;
}

export interface PaginationParams {
  page: number;
  pageSize: number;
}

/**
 * @description:  上传算法
 * @param formData
 */
export function UploadAlgorithms(formData: FormData) {
  return Alova.Post('/upload/file ', formData, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

/**
 * @description: 获取算法列表
 * @param params 分页参数
 * @returns 包含算法列表和总数的响应对象
 */
export function GetAlgorithms(params: PaginationParams) {
  return Alova.Get<Algorithm[]>('/algorithm/list', {
    params: {
      isInstalled: false,
      page: params.page,
      pageSize: params.pageSize
    }
  });
}

// 安装算法
export function InstallAlgorithm(id: number) {
  return Alova.Post('/algorithm/install', { id });
}

// 卸载算法
export function UninstallAlgorithm(id: number) {
  return Alova.Post('/algorithm/uninstall', { id });
}
